package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.RedPacketRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface RedPacketRecordMapper {
    @Delete({
        "delete from red_packet_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into red_packet_record (id, chat_id, ",
        "sender_uid, receiver_uid, ",
        "red_packet_id, red_packet_name, ",
        "red_packet_coin, create_time)",
        "values (#{id,jdbcType=INTEGER}, #{chatId,jdbcType=BIGINT}, ",
        "#{senderUid,jdbcType=BIGINT}, #{receiverUid,jdbcType=BIGINT}, ",
        "#{redPacketId,jdbcType=BIGINT}, #{redPacketName,jdbcType=VARCHAR}, ",
        "#{redPacketCoin,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(RedPacketRecord record);

    int insertSelective(RedPacketRecord record);

    @Select({
        "select",
        "id, chat_id, sender_uid, receiver_uid, red_packet_id, red_packet_name, red_packet_coin, ",
        "create_time",
        "from red_packet_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    RedPacketRecord selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(RedPacketRecord record);

    @Update({
        "update red_packet_record",
        "set chat_id = #{chatId,jdbcType=BIGINT},",
          "sender_uid = #{senderUid,jdbcType=BIGINT},",
          "receiver_uid = #{receiverUid,jdbcType=BIGINT},",
          "red_packet_id = #{redPacketId,jdbcType=BIGINT},",
          "red_packet_name = #{redPacketName,jdbcType=VARCHAR},",
          "red_packet_coin = #{redPacketCoin,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(RedPacketRecord record);
}